#!/usr/local/bin/pl -g serql_welcome -L0 -G0 -T0 -s

% Needs SeRQL in the path

:- dynamic
        user:file_search_path/2.
:- multifile
        user:file_search_path/2.

:- prolog_load_context(directory, Dir),
   atom_concat(Dir,'/SeRQL',SeRQLDir),
   asserta(user:file_search_path(serql, SeRQLDir)).

:- load_files([ serql(load)
              ],
              [ silent(true)
              ]).



% P2R code

:- use_module('p2r/p2r_entailment').



% Handcrafted mappings

:- use_module('toc/toc_mapping').


:- compile.

:-
	writeln(' - Dumping data in dump/toc.ttl ...'),
	open('dump/toc.ttl',write,S), % we ll dump triples by triples to avoid stack troubles
	forall(
		p2r_entailment:rdf(A,B,C)
		,
		C=literal(Literal) ->
			format(S,'<~w> <~w> "~w".\n',[A,B,Literal]) ; format(S,'<~w> <~w> <~w>.\n',[A,B,C])
		),
	close(S),writeln(' - Done').

:- halt.
